home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / GameKit / Headers / gamekit / PlayerUpView.h < prev    next >
Text File  |  1995-06-12  |  3KB  |  66 lines

  1.  
  2. // PlayerUpView is used to track one-ups.  (i.e. the number of extra
  3. // "men" left.)  It handles displaying them on the screen, too; use
  4. // is fairly obvious:
  5. //            1.  Initialize: -initFrame, -setImage:, -setImageFrame:
  6. //                    -setMargin: (optional method, default is 2.0)
  7. //            2.    Reset at start of game play with -setNumUp:
  8. //            3.    When an extra "man" is needed, call -decNumUp:  If it
  9. //                    returns YES, then you got one.  If it returns NO
  10. //                    then there are no more left and the game is over.
  11. //            4.    If the player is to be awarded a bonus "extra man"
  12. //                    then call -incNumUp: to add one extra "man".
  13. //                    If you set up an appropriate BonusTacker (or subclass),
  14. //                    send it to the PlayerUpView, and then make the
  15. //                    PlayerUpView one of the delegates to the ScoreKeeper,
  16. //                    then it will automatically give extra one-ups at the
  17. //                    right times.
  18. //            5.    If you need to know how many are left, then use
  19. //                    the -numUp method to find out.  (If you need to
  20. //                    inc by more than one, for example, use a combo
  21. //                    like: [playerUpView setNumUp:([playerUpView numUp] + x)];
  22. //            6.    Set the delegate outlet if you want notification of bonus
  23. //                    men, added/subtracted men, and so on.  (Trigger sounds
  24. //                    and music off the notification, etc.)
  25. // Note that the NeXT archiving works via -read: and -write: so that
  26. //        this object can be on a palette.
  27.  
  28. #import <appkit/appkit.h>
  29.  
  30. @interface PlayerUpView:View
  31. {
  32.     id    image;            // an NXImage of the one up
  33.     id    delegate;        // any object...
  34.     id    extraManBonusTracker;    // a BonusTracker...when to give xtra men
  35.     int numUp;            // how many chances the player has left
  36.     NXCoord margin;        // amount of white space to leave when rendering
  37.     NXRect imageFrame;    // where the one up image is located in "image"
  38. }
  39.  
  40. // before using this object, you should use the following methods, in
  41. // this order, to set things up.
  42. - initFrame:(const NXRect *)frm;    // for initting a view
  43. - setImage:anImage;                    // bitmap image of a oneUp
  44. - setMargin:(NXCoord)newMargin;        // white space around displayed oneUps
  45. - setImageFrame:(NXRect *)aRect;    // where the oneUp pic is in the image
  46. - setNumUp:(int)newNumUp;    // set # of oneUps; use at start of game play
  47.  
  48. // -setNumUp: and the next three methods are for use by the game.
  49. - incNumUp:sender;            // add a oneUp (awarded bonuses or whatever)
  50. - (int)numUp;                // how many oneUps are left
  51. - (BOOL)decNumUp:sender;    // use a oneUp & update view
  52.  
  53. - drawSelf:(NXRect *)rects :(int)rectCount;    // render the view
  54. - read:(NXTypedStream *)stream;        // for archiving & palettes
  55. - write:(NXTypedStream *)stream;    // for archiving & palettes
  56.  
  57. // give away extra guys; we act as delegate to ScoreKeeper and wait for
  58. // the score to cross critical points...
  59. - scoreChangedFrom:(int)oldScore to:(int)newScore;
  60. - setExtraManBonusTracker:tracker;
  61. - setDelegate:anObject;
  62. - extraManBonusTracker;
  63. - delegate;
  64.  
  65. @end
  66.